package com.ruoyi.property.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.property.domain.PrestoreFeeInfo;
import com.ruoyi.property.service.IPrestoreFeeInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 预付费用信息Controller
 * 
 * @author sux
 * @date 2021-06-29
 */
@Controller
@RequestMapping("/property/prestoreFeeInfo")
public class PrestoreFeeInfoController extends BaseController
{
    private String prefix = "property/prestoreFeeInfo";

    @Autowired
    private IPrestoreFeeInfoService prestoreFeeInfoService;

    @RequiresPermissions("property:prestoreFeeInfo:view")
    @GetMapping()
    public String prestoreFeeInfo()
    {
        return prefix + "/prestoreFeeInfo";
    }

    /**
     * 查询预付费用信息列表
     */
    @RequiresPermissions("property:prestoreFeeInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PrestoreFeeInfo prestoreFeeInfo)
    {
        startPage();
        List<PrestoreFeeInfo> list = prestoreFeeInfoService.selectPrestoreFeeInfoList(prestoreFeeInfo);
        return getDataTable(list);
    }

    /**
     * 导出预付费用信息列表
     */
    @RequiresPermissions("property:prestoreFeeInfo:export")
    @Log(title = "预付费用信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PrestoreFeeInfo prestoreFeeInfo)
    {
        List<PrestoreFeeInfo> list = prestoreFeeInfoService.selectPrestoreFeeInfoList(prestoreFeeInfo);
        ExcelUtil<PrestoreFeeInfo> util = new ExcelUtil<PrestoreFeeInfo>(PrestoreFeeInfo.class);
        return util.exportExcel(list, "prestoreFeeInfo");
    }

    /**
     * 新增预付费用信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存预付费用信息
     */
    @RequiresPermissions("property:prestoreFeeInfo:add")
    @Log(title = "预付费用信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PrestoreFeeInfo prestoreFeeInfo)
    {
        return toAjax(prestoreFeeInfoService.insertPrestoreFeeInfo(prestoreFeeInfo));
    }

    /**
     * 修改预付费用信息
     */
    @GetMapping("/edit/{prestoreId}")
    public String edit(@PathVariable("prestoreId") Long prestoreId, ModelMap mmap)
    {
        PrestoreFeeInfo prestoreFeeInfo = prestoreFeeInfoService.selectPrestoreFeeInfoById(prestoreId);
        mmap.put("prestoreFeeInfo", prestoreFeeInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存预付费用信息
     */
    @RequiresPermissions("property:prestoreFeeInfo:edit")
    @Log(title = "预付费用信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PrestoreFeeInfo prestoreFeeInfo)
    {
        return toAjax(prestoreFeeInfoService.updatePrestoreFeeInfo(prestoreFeeInfo));
    }

    /**
     * 删除预付费用信息
     */
    @RequiresPermissions("property:prestoreFeeInfo:remove")
    @Log(title = "预付费用信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(prestoreFeeInfoService.deletePrestoreFeeInfoByIds(ids));
    }
}
